/* Copyright (c) Oracle Corporation 1992.  All Rights Reserved */

/**************************************************************************** 
  NAME
    rdbms72.ins - Windows 95 V3 installation script for the Personal
		  Oracle7 RDBMS.

  DESCRIPTION
    This script installs the Personal Oracle7 RDBMS by copying the appropriate
    files and optionally creating a new database by using a "seed" database.

  OWNER
    Tony Rodgers

  MODIFIED    DD-MMM-YY Reason
   LMurphy     06/13/95 - Modified for 7.2/Windows 95
   LMurphy     11/29/94 - modified NT RDBMS script for Personal Oracle7
   syau        07/01/94 - 7.1.3
    HA!        04/28/94 - 7.1.2 and 3.0.10.2
   Hartenstine 04/20/93 - WIN_NT: Adapt to Windows NT
    Colello    10/09/92 - DESKTOP: copy demo and doc files AND add
			     DBA_AUTHORIZATION
    trodgers  01-APR-92 Created.
*****************************************************************************/
{
  /************************************************************************** 
	    Start main logic...                               
   **************************************************************************/
  if (doit)
    {

      bmp_home = directory_name(current_script);
      { ui_graphics("%bmp_home%\database.bmp"); }
      [ 'DEFAULT: continue(); ]

      ins_ratchet = "7.2.2.3.1";

      execute("%installer_home%\win95.ins");

      install(w95rsf72);
      install(w95util72);

      ui_product(product_label);             

      permit_retry_operations = TRUE;        

      ui_action(instantiate(installing_scripts));
      copy(deinstl);
      ui_action(instantiate(installing_executables));    
      copy(exec, vsn);
      copy(doc);
      copy(help);
      copy(init);

      ui_action(instantiate(installing_dlls));
      copy(dll, vsn);
      copy(twotask);
      copy(res, nls_abbreviation);

      ui_action(instantiate(installing_msg));    
      copy(msg, nls_abbreviation);

      ui_action(instantiate(installing_sql));
      copy(sql);

      ui_action(instantiate(modifying_config));
      if (set_rdbms72)
      {
        modify("RDBMS72",rdbms72,ora_config,(product_filename(w95rsf72)));
      }

      modify("RDBMS_FILES",rdbms_files,ora_config,(product_filename(current_product)));
      modify("ORACLE_SID","orcl",ora_config,(product_filename(current_product)));

/* Backup and Recovery registry items */

      if (set_mshelp)
      {
           ui_action(instantiate(modifying_config));
	   modify("MSHELP",mshelp,ora_config,(product_filename(current_product)));
      }


      modify("MSHELP_TOOLS",mshelp,ora_config,(product_filename(current_product)));
      modify("VS10","%oracle_home%\BIN",ora_config,(product_filename(current_product)));
      modify("RDBMS72_CONTROL",rdbms_files,ora_config,(product_filename(current_product)));
      modify("RDBMS72_ARCHIVE","%rdbms72%\ARCHIVE",ora_config,(product_filename(current_product)));


      bmp_home = directory_name(current_script);
      { ui_graphics("%bmp_home%\repdb.bmp"); }
      [ 'DEFAULT: continue(); ]

      if (install_seed_database)
      {
	copy_seed = TRUE;
	modify("DATABASE_STARTUP","",ora_config,(product_filename(current_product)));
	modify("LISTENER_STARTUP","",ora_config,(product_filename(w95netsrv22)));
	ui_action(instantiate(installing_seed));
        if (new_seed_path)
	{
		{ make_directory("%rdbms_home%"); }
		[ 'INVALID_FILE_NAME, 'PERMISSION_ERROR, 'FILE_NOT_FOUND, 'WRITE_ERROR, 'OS_ERROR:
		  {
			copy_seed = FALSE;
                        information_dialog(new_seed_dir_failed);
		  }
		]
		if (copy_seed)
		{
			copy(seed, db_type);
		}
	}
	else
	{
		copy(seed, db_type);
	}

	permit_retry_operations = FALSE;

	if (exists("%ORACLE_HOME%\DATABASE\pwdorcl.ora"))
		remove_file("%ORACLE_HOME%\DATABASE\pwdorcl.ora");

	ui_action(instantiate(setting_password));
	{
	  spawn("%ORACLE_HOME%\BIN\ORAPWD72.EXE file=%ORACLE_HOME%\DATABASE\pwdorcl.ora password=oracle");
	} 
        [ 'NO_RESPONSE: continue();
	  'INVALID_FILE_NAME, 'OS_ERROR: 
	  {
		information_dialog(orapwd_err);
	  }
	]

	modify("DBA_AUTHORIZATION","oracle",ora_config,(product_filename(current_product)));

	/* Startup Database by running a script on SQL*DBA */    
	ui_action(instantiate(starting_up));
	sqldba_run = TRUE;
	{
	spawn("%ORACLE_HOME%\BIN\SQLDBA72.EXE @%RDBMS72%\ADMIN\createdb.sql");
	} 
	[ 'NO_RESPONSE: continue();
	  'INVALID_FILE_NAME, 'OS_ERROR: 
	  {
		sqldba_run = FALSE;
		information_dialog(sqldba_err);
	  }
	]
	
	err_seen = FALSE;
	{
	ora_err = translate("ORA", "%RDBMS72%\TRACE\build.log", "-");
	err_seen=TRUE;
	information_dialog(sqldba_fail);
	}
	[
	 'UNBOUND_ENVIRONMENT_VARIABLE: continue();
	 'OS_ERROR, 'READ_ERROR, 'INVALID_FILE_NAME, 'DEFAULT:
	 {
		err_seen=TRUE;
		information_dialog(no_build_log);
	 }
	]
	{
	if (not(err_seen))
	{
		dba_err = translate("DBA", "%RDBMS72%\TRACE\build.log", "-");
		err_seen=TRUE;
		information_dialog(sqldba_fail);	
	}
	}
	[
	 'UNBOUND_ENVIRONMENT_VARIABLE: continue();
	 'OS_ERROR, 'READ_ERROR, 'INVALID_FILE_NAME:
	 {
		err_seen=TRUE;
		information_dialog(no_build_log);
	 }
	]
	{
	if (not(err_seen))
	{
		inst_err = translate("INST", "%RDBMS72%\TRACE\build.log", "-");
		err_seen=TRUE;
		information_dialog(sqldba_fail);	
	}
	}
	[
	 'UNBOUND_ENVIRONMENT_VARIABLE: continue();
	 'OS_ERROR, 'READ_ERROR, 'INVALID_FILE_NAME:
		information_dialog(no_build_log);
	]

	if (sqldba_run)
	{
	spawn("%ORACLE_HOME%\BIN\knlstop");
	}
	[ 'NO_RESPONSE: continue();
	  'INVALID_FILE_NAME, 'OS_ERROR: 
	  {
		information_dialog(orakill_err);
	  }
	]

        permit_retry_operations = TRUE;	

      }      

      if (registered("w95netsrv22"))
	modify("LISTENER_STARTUP","AUTO",ora_config,(product_filename(w95netsrv22)));      
      modify("DATABASE_STARTUP","AUTO",ora_config,(product_filename(current_product)));


      /*****************
      Install the parent
      ******************/

      if(member(selected_products, current_product))
      {
	if (install_parent)
		install(product_parent(current_product));
      }

      ui_action(instantiate(registering));
      register(current_product, comment);
      if (member(selected_products,current_product))
	reference(current_product);

      reference(w95rsf72, current_product);
      reference(w95util72, current_product);

      /* reference parent */
      reference(product_parent(current_product), current_product);
/* LMurphy - 07/11/95 - reference parent for util72 because if 
util72 called from rdbms72 as dependent product, parent doesn't
get installed (install_parent=false) before reference call in util72.ins
and error caused */
      reference(product_parent(current_product), w95util72);

      permit_retry_operations = FALSE;
    }
}
